<?php


namespace app\validate\api;


class IDCollection extends BaseValidate
{
    protected $rule = [
        'ids'=>'require|CheckIDs'
    ];

    protected $message = [
        'ids'=>'ids参数必须是以逗号分隔的多个正整数'
    ];

    public function CheckIDs($value,$rules='',$data='',$field=''): bool
    {
        $values = explode(',',$value);
        if(empty($values)){
            return false;
        }
        foreach ($values as $id){
            if($this->isPositiveInteger($id)!==true){
                return false;
            }
        }
        return true;
    }
}